function replaceUrl(arr, fun) {
  return arr.map(item => {
    return fun(item)
  })
}

export function replaceimageUrl(arr) {
  if(Array.isArray(arr)) {
    return replaceUrl(arr, (item) => {
      if(item.hasOwnProperty('picUrl')) {
        const endIndex = item.picUrl.indexOf('net')
        item.picUrl = 'http://39.97.253.1/image' + item.picUrl.slice(endIndex + 3)
        return item
      } else if(item.hasOwnProperty('imageUrl')) {
        const endIndex = item.imageUrl.indexOf('net')
        item.imageUrl = 'http://39.97.253.1/image' + item.imageUrl.slice(endIndex + 3)
        return item
      }
      return item
    })
  }
  if(typeof(arr) === 'string') {
    return 'http://39.97.253.1/image' + arr.slice(arr.indexOf('net') + 3)
  }
}